package com.pctc.service.impl;

import com.pctc.dao.BookMapper;
import com.pctc.domain.Book;
import com.pctc.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BookServiceImpl implements BookService {

    @Autowired
    private BookMapper bookMapper;


    //查询统计不用事务处理
    @Transactional(readOnly = true)
    public Book findBookById(Integer id) {
        return bookMapper.findBookById(id);
    }

    @Override
    public int addBook(Book book) {
        if(book!=null) {
            //bookMapper.addBook(book);
            //int a=10/0;
            return bookMapper.addBook(book);
        }
        else
            return 0;
    }


}

